<template>
	<view class="library">
		<image :src="'http://124.93.196.45:10001'+detail.imgUrl" style="width: 100%;"></image>
		<view class="l1">
			<text>{{detail.name}}</text>
			<text>地址：{{detail.address}}</text>
			<text>营业时间:{{detail.businessHours}}</text>
			<text>营业状态：营业</text>
		</view>
		<view class="l2">
			<text>简介：{{detail.description}}</text>
		</view>
		<view class="l3">
			<textarea placeholder="发送一条友善的评论吧" v-model="value" ></textarea>
			<u-button text="发送" color="#ccc" @click="addcommrnt"></u-button>
		</view>
		<u-button type="primary" text="查看评论"></u-button>
		<view class="l4">
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				detail:{},
				value:'',
				coment:[]
			}
		},
		onLoad(options) {
			this.id=options.id
			this.getdetail()
		},
		methods: {
			getdetail(){
				this.api.get('/prod-api/api/digital-library/library/'+this.id).then(res=>{
					this.detail=res.data.data
					console.log(this.detail)
				})
			},
			getcoment(){
				this.api.get('')
			},
			addcommrnt(){
				if(this.value===''){
					uni.showToast({
						title:'内容为空',
						icon:'error'
					})
					return
				}
				const data={
					libraryId:this.id,
					content:this.value
				}
				this.api.get('/prod-api/api/digital-library/library-comment','POST',data).then(res=>{
					if(res.data.code===200){
						setTimeout(function(){
							uni.showToast({
								title:'发送成功'
							})
						},700)
						this.value=''
					}else{
						console.log(res.data)
						setTimeout(function(){
							uni.showToast({
								title:'发送失败',
								icon:'error'
							})
						},700)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.l1{
	display: flex;
	flex-direction: column;
	text-align: center;
	line-height: 30px;
	margin-bottom: 10px;
	font-size: 18px;
}
.l2{
	line-height: 26px;
	font-size: 17px;
}
.l3{
	width: 300px;
	margin: 30px auto;
}
</style>
